
package soccer.utility.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class ConnectionManager {
	public  String classname ="com.mysql.jdbc.Driver";
    private String username = "root";
	private String password = "3254";
	private String url      ="jdbc:mysql://localhost:3306/soccer?zeroDateTimeBehavior=convertToNull";
	private static  ConnectionManager  connectioninstance = null;

	
public static synchronized  ConnectionManager  getInstance(){
	    if(connectioninstance == null){
	    	connectioninstance = new ConnectionManager();
	    	
	    }
	    return connectioninstance;
}

public  Connection getConnection(){	 
        Connection conn = null;
        try{
        	Class.forName(classname);
        	conn = DriverManager.getConnection(url,username,password);
        	System.out.println("connection establish"); // NOPMD by pasa on 5/13/11 5:22 PM
        }
        
       catch (ClassNotFoundException e) {
	       e.printStackTrace();
       } catch (SQLException e) {
	  e.printStackTrace();
      }
   return conn;
}

public void closeConnection(Connection conn){
	  try {
		  conn.close();
	  } catch (SQLException e) {
		  e.printStackTrace();
	  }
} 

}
